﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ModelContextProtocol.Client;

namespace MCPServerConsole
{
    internal class Program
    {
        static async Task Main(string[] args)
        {
            try
            {
                Console.WriteLine("Starting MCP Server...");
                var builder = Host.CreateEmptyApplicationBuilder(settings: null);
                builder.Services.AddMcpServer()
                               .WithStdioServerTransport()
                               .WithToolsFromAssembly(typeof(MCPTool.Tools.CalcTool).Assembly);//自动注册当前程序集中的所有 MCP 工具
                await builder.Build().RunAsync();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Host terminated unexpectedly : {ex.Message}");
            }
        }
    }
}
